//
//  OrderCell.m
//  体育商城
//
//  Created by  on 2022/9/24.
//

#import "OrderCell.h"
@interface OrderCell()
@property (strong, nonatomic) IBOutlet UIButton *nameBtn;
@property (strong, nonatomic) IBOutlet UIImageView *picture;
@property (strong, nonatomic) IBOutlet UILabel *title;
@property (strong, nonatomic) IBOutlet UILabel *tips;
@property (strong, nonatomic) IBOutlet UILabel *money;
@property (strong, nonatomic) IBOutlet UILabel *statuts;
@property (strong, nonatomic) IBOutlet UILabel *price;
@property (strong, nonatomic) IBOutlet UIButton *rightBtn;
@property (strong, nonatomic) IBOutlet UIButton *leftBtn;
@end
@implementation OrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
- (IBAction)actionForBtn:(UIButton *)sender {
    if (sender.tag == 201){
        if (self.block) {
            self.block(LS(@"商店"));
        }
    }else{
        if (self.block) {
            self.block(sender.currentTitle);
        }
    }
}
- (void)setModel:(Goods *)model{
    if (_model != model) {
        _model = model;
        self.picture.image = nil;
        self.title.text = [NSString stringWithFormat:@"%@",model.brandName];
        self.price.text = [NSString stringWithFormat:LS(@"¥:%@"),model.price];
        self.money.text = [NSString stringWithFormat:LS(@"¥:%@"),model.price];
        self.tips.text = [NSString stringWithFormat:LS(@"月销量%d万+"),[model.productReference intValue] / 10000];
        [self.nameBtn setTitle:model.name forState:UIControlStateNormal];
        self.task = [UIImage imageWithURL:model.mainImage block:^(UIImage * _Nonnull image) {
            self.picture.image = image;
        }];
        
        switch (model.orderStatus) {
            case GoodsOrderStastusDefault:
            {
                [self.leftBtn setTitle:LS(@"删除订单") forState:UIControlStateNormal];
                [self.rightBtn setTitle:LS(@"加入购物车") forState:UIControlStateNormal];
                self.statuts.text = LS(@"交易完成");
            }
                break;
            case GoodsOrderStastusFavorite:
            case GoodsOrderStastusNoPayed:
            case GoodsOrderStastusJoinCart:
            {
                [self.leftBtn setTitle:LS(@"取消") forState:UIControlStateNormal];
                [self.rightBtn setTitle:LS(@"去付款") forState:UIControlStateNormal];
                self.statuts.text = LS(@"等待买家去付款");
            }
                break;
            case GoodsOrderStastusPayed:
            case GoodsOrderStastusNoShip:
            {
                [self.leftBtn setTitle:LS(@"催发货") forState:UIControlStateNormal];
                [self.rightBtn setTitle:LS(@"修改地址") forState:UIControlStateNormal];
                self.statuts.text = LS(@"买家已付款");
            }
                break;
            case GoodsOrderStastusNoReceipt:
            {
                [self.leftBtn setTitle:LS(@"确认收货") forState:UIControlStateNormal];
                [self.rightBtn setTitle:LS(@"退款") forState:UIControlStateNormal];
                self.statuts.text = LS(@"卖家已发货");
            }
                break;
            case GoodsOrderStastusAfterSales:
            {
                [self.leftBtn setTitle:LS(@"删除记录") forState:UIControlStateNormal];
                [self.rightBtn setTitle:LS(@"退款状态") forState:UIControlStateNormal];
                self.statuts.text = LS(@"卖家已发货");
            }
                break;
        }
        
    }
}
@end
